#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct tree
{
	int r;
	int c;
	struct tree* left;
	struct tree* right;
	struct tree* mid;
}tree;
int flag(int x)
{
	int i = 0;
	for (i = 2; i < x; i++)
	{
		if (x % i == 0)
		{
			return 0;
		}
	}
	return 1;
}
int fac(int x, int y)
{
	return y == 0 ? x : fac(y, x % y);
}
int cmp(const void* p1, const void* p2)
{
	return *(int*)p2 - *(int*)p1;
}
void Inittree(tree* pt)
{
	pt->r = 0;
	pt->c = 0;
	pt->left = pt->right = pt->mid = NULL;
}
void Printtree(tree* pt)
{
	if (pt == NULL)
		return;
	printf("%d %d \n", pt->r, pt->c);
	Printtree(pt->left);
	Printtree(pt->mid);
	Printtree(pt->right);
}
void Push(tree* pt, char str[], int* n)
{
	if (pt == NULL)
	{
		return;
	}


	tree* newnode = (tree*)malloc(sizeof(tree));
	newnode->left = newnode->right = newnode->mid = NULL;
	if (str[*n] == 'L')
	{
		newnode->r = pt->r;
		newnode->c = pt->c - 1;
		pt->left = newnode;
		(*n)++;
		Push(pt->left, str, n);
	}
	else if (str[*n] == 'F')
	{
		newnode->r = pt->r - 1;
		newnode->c = pt->c;
		pt->mid = newnode;
		(*n)++;
		Push(pt->mid, str, n);
	}
	else if (str[*n] == 'R')
	{

		newnode->r = pt->r;
		newnode->c = pt->c + 1;
		pt->right = newnode;
		(*n)++;
		Push(pt->right, str, n);
	}


}
int main()
{
	int n = 0;
	scanf("%d", &n);
	char* str = (char*)malloc(sizeof(char) * n);
	scanf("%s", str);
	int len = strlen(str);
	tree TT;
	Inittree(&TT);
	int x = 0;
	Push(&TT, str, &x);
	Printtree(&TT);
	return 0;
}
int main9()
{
	int n, m;
	int arr[300][300];
	scanf("%d%d", &n, &m);
	int i, j;

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
		{
			scanf("%d", &arr[i][j]);
		}
	}
	int x1, y1, x2, y2;
	x1 = 0, x2 = 0; y1 = 0, y2 = 0;
	int max = 0;
	for (x1 = 0; x1 <= x2; x1++)
	{
		for (y1 = 0; y1 <= y2; y2++)
		{
			for (x2 = x1 + 1; x2 < n; x2++)
			{
				for (y2 = y1 + 1; y2 < m; y2++)
				{
					int x = x2 - x1;
					int y = y2 - y1;
					int sum = 0;
					for (i = x1; i <= x2; i++)
					{
						for (j = y1; j <= y2; j++)
						{
							sum += arr[i][j];

						}
					}
					if (sum > max)
					{
						max = sum;
					}
				}
			}
		}
	}
	printf("%d", max);
	return 0;
}
/*int main4()
{
	tree TT;
	Inittree(&TT);
	Push(&TT);
	return 0;
}*/
int main8()
{
	char str[] = "LANQIAO";
	char str2[1000];
	scanf("%s", str2);
	int len2 = strlen(str2);
	int len = strlen(str);
	int flag = 0;
	int i = 0;
	int j = 0;
	for (i = 0; i < len2; i++)
	{
		if (str2[i] == str[j])
		{
			j++;
			if (j == len)
			{
				flag = 1;
				break;
			}
		}
	}
	if (flag == 1)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
}
int main7()
{
	int n = 0;
	scanf("%d", &n);
	int* arr = (int*)malloc(sizeof(int) * n);
	int i = 0;

	for (i = 0; i < n; i++)
	{
		scanf("%d", arr + i);

	}
	int min = 1000001;
	for (i = 0; i < n; i++)
	{
		if (arr[i] < min && (arr[i] % 2 == 0))
		{
			min = arr[i];
		}
	}
	printf("%d", min);
	return 0;
}
int main6()
{
	int num = 2024;
	int n;
	scanf("%d", &n);
	int x = num / n;
	if (num % n != 0)
	{
		x++;
	}
	printf("%d", x);
	return 0;
}
int main5()
{
	int arr[100] = { 534, 386, 319, 692, 169, 338, 521, 713, 640, 692, 969, 362, 311, 349, 308, 357, 515, 140, 591, 216,

57, 252, 575, 630, 95, 274, 328, 614, 18, 605, 17, 980, 166, 112, 997, 37, 584, 64, 442, 495,

821, 459, 453, 597, 187, 734, 827, 950, 679, 78, 769, 661, 452, 983, 356, 217, 394, 342, 697, 878,

475, 250, 468, 33, 966, 742, 436, 343, 255, 944, 588, 734, 540, 508, 779, 881, 153, 928, 764, 703,

459, 840, 949, 500, 648, 163, 547, 780, 749, 132, 546, 199, 701, 448, 265, 263, 87, 45, 828, 634 };
	qsort(arr, 100, sizeof(int), cmp);
	int i = 0;
	int sum = 0;
	for (i = 0; i < 100; i++)
	{
		printf("%d ", arr[i]);
		sum += arr[i];
	}

	printf("\n%d", sum);
	int x = sum % 24;
	printf(" %d", sum % 24);
	return 0;
}
/*
int main4()
{
	int i=0;
	int count=0;
	for(i=1;i<=2024;i++)
	{
		if((i^2024)<2024)
		{
			printf("%d ",i^2024);
			count++;
		}
	}
	printf("\n%d",count);
	return 0;
}*/
int main2()
{
	int a, b;
	a = 2024, b = 2014;
	int c = fac(a, b);
	printf("%d", a * b / c);
	return 0;
}

int main1()
{
	int p, a;
	a = 2024;
	int i = 0;
	int max = 0;
	for (i = 1; i < a; i++)
	{
		if (flag(i) && (a % i == 0))
		{
			max = i;
		}
	}
	printf("%d", max);
	return 0;
}